*REPLICATION FILES
//THE INTERNATIONAL BORDER AGREEMENTS DATASET
//OWSIAK, ANDREW P., ALLISON CUTTNER, AND BRENT BUCK
//CONFLICT MANAGEMENT AND PEACE SCIENCE

*This file reproduces all the tables, figures, and statistics discussed within both the main text and appendix.

use "Replication - IBAD Settlement Process Attempt-Year.dta"
sort dyad intstartyear

*I. DESCRIPTIVE STATISTICS USED IN TEXT
* Find unique conflict management attempts: a) tag unique, b) running sum of unique, c) maximum of running sum.
gen unique=1 if ongoing==0
replace unique=0 if unique==.
by dyad: gen sumunique=sum(unique) 
by dyad: egen maxunique=max(sumunique)
tab maxun
by dyad: gen obs=_n

*Find number of attempts per dyad (i.e., maximum of running sum at first obs of dyads obs)
tab maxun if obs==1
//29 dyads of 281 have one and only one conflict management attempt (10.32% of all dyads)
*Identify dyads and years for these observations
list dyad intstartyear if obs==1 & maxun==1
//Prior to 1914 (WWI) in Europe: 11
//Post WWI/WWII: WWI (4) WWII (4) = 8


*Find (any) usage of various strategies within each dyad 
sort dyad intstartyear

gen countnegotiation=1 if negotiation==1 & unique==1
replace countnegotiation=0 if countnegotiation==.

gen countmediation=1 if mediation==1 & unique==1
replace countmediation=0 if countmediation==.

gen countarbitration=1 if arbitration==1 & unique==1
replace countarbitration=0 if countarbitration==.

gen countadjudication=1 if adjudication==1 & unique==1
replace countadjudication=0 if countadjudication==.

gen countforce=1 if force==1 & unique==1
replace countforce=0 if countforce==.

gen countpostwarcon=1 if postwarcon==1 & unique==1
replace countpostwarcon=0 if countpostwarcon==.

gen countpleb=1 if pleb==1 & unique==1
replace countpleb=0 if countpleb==.

gen countinternaldecree=1 if internaldecree==1 & unique==1
replace countinternaldecree=0 if countinternaldecree==.

*Create variable for each strategy, where 1=used in dyad, 0=not
by dyad: egen maxnegotiation=max(countnegotiation)
by dyad: egen maxmediation=max(countmediation)
by dyad: egen maxarbitration=max(countarbitration)
by dyad: egen maxadjudication=max(countadjudication)
by dyad: egen maxforce=max(countforce)
by dyad: egen maxpostwarconf=max(countpostwarcon)
by dyad: egen maxpleb=max(countpleb)
by dyad: egen maxinternaldecree=max(countinternaldecree)

*Sum strategy usage. Because each variable above=0/1, sum>1==more than one strategy used.
by dyad: gen allcmtypes=maxnegotiation+maxmediation+maxarbitration+maxadjudication+maxforce+maxpostwarconf+maxpleb+maxinternaldecree
*Tab strategy usage, but limit to obs==1 to reduce to one obs/dyad
tab allcmtypes if obs==1
//60.85% of all dyads use more than one conflict management strategy (1-.3915)

*Determine unique attempts pre- and post- de jure settlement
tab unique settle, r
//36.35% of all conflict management attempts appear post- de jure settlement


*II. Settlement Graphs 
use "Replication - IBAD Full Settle Dyad-Year.dta", clear
drop if year>2001
keep if conttype==1

** FIGURE 1: UNIQUE SETTLEMENTS BY YEAR
*Generate settlement in data
sort dyad year
gen settled=1 if settle==1 & obs==1
by dyad: replace settled=1 if settle==1 & settle[_n-1]==0
sort year
by year: egen totalsettled=total(settled)

graph twoway line totalsettled year
tab totalsettled


*FIGURE 2: SETTLEMENT PATTERNS BY REGION
gen missing=0 if settle!=.
replace missing=1 if settle==.

*Generate region variables 
gen region=1 if ccode1<199
replace region=2 if ccode1>199 & ccode1<400
replace region=3 if ccode1>399 & ccode1<600
replace region=4 if ccode1>599 & ccode1<700
replace region=5 if ccode1>699

gen Americas=1 if region==1
replace Americas=0 if Americas==.

gen Europe=1 if region==2
replace Europe=0 if Europe==.

gen Africa=1 if region==3
replace Africa=0 if Africa==.

gen MiddleEast=1 if region==4
replace MiddleEast=0 if MiddleEast==.

gen Asia=1 if region==5
replace Asia=0 if Asia==.

gen didyad=1

sort year
by year: egen totalmissing=total(missing) 
by year: egen totaldyads=total(didyad)
by year: egen totalsettle1=total(settle) if missing==0
by year: gen totalsettleratio1=(totalsettle1/(totaldyads-totalmissing)) if missing==0
graph twoway line totalsettleratio1 year

by year: egen totalsettleAmer1=total(settle) if missing==0 & Americas==1
by year: egen totalmissingAmer1=total(missing) if Americas==1
by year: egen totalAmer=total(Americas)
by year: gen totalratioAmer1=(totalsettleAmer1/(totalAmer-totalmissingAmer1)) if missing==0 & Americas==1
graph twoway line totalratioAmer1 year

by year: egen totalsettleEur1=total(settle) if missing==0 & Europe==1
by year: egen totalmissingEur1=total(missing) if Europe==1
by year: egen totalEur=total(Europe)
by year: gen totalratioEur1=(totalsettleEur1/(totalEur-totalmissingEur1)) if missing==0 & Europe==1
graph twoway line totalratioEur1 year

by year: egen totalsettleAfr1=total(settle) if missing==0 & Africa==1
by year: egen totalmissingAfr1=total(missing) if Africa==1
by year: egen totalAfr=total(Africa)
by year: gen totalratioAfr1=(totalsettleAfr1/(totalAfr-totalmissingAfr1)) if missing==0 & Africa==1
graph twoway line totalratioAfr1 year

by year: egen totalsettleME1=total(settle) if missing==0 & MiddleEast==1
by year: egen totalmissingME1=total(missing) if MiddleEast==1
by year: egen totalME=total(MiddleEast)
by year: gen totalratioME1=(totalsettleME1/(totalME-totalmissingME1)) if missing==0 & MiddleEast==1
graph twoway line totalratioME1 year

by year: egen totalsettleAsia1=total(settle) if missing==0 & Asia==1
by year: egen totalmissingAsia1=total(missing) if Asia==1
by year: egen totalAsia=total(Asia)
by year: gen totalratioAsia1=(totalsettleAsia1/(totalAsia-totalmissingAsia1)) if missing==0 & Asia==1
graph twoway line totalratioAsia1 year

//Above individual graphs can be saved and combined using the following command:
//graph combine F2allregions.gph F2americas.gph F2europe.gph F2africa.gph F2mena.gph F2asia.gph, r(2) c(3) altshrink

*Get exact values by year by focusing on one dyad/region
list year totalratioAmer if totalratioAmer!=. & dyad==100101
list year totalratioEur if totalratioEur!=. & dyad==210211
list year totalratioEur if totalratioEur!=. & dyad==220255
list year totalratioAfr1 if totalratioAfr!=. & dyad==530625
list year totalratioME1 if totalratioME!=. & dyad==630640
list year totalratioAsia1 if totalratioAsia!=. & dyad==710712


*FIGURE 4: MISSING DATA 
sort year
by year: gen ratiomissing=totalmissing/totaldyads
graph twoway line ratiomissing year
list year ratiomissing if dyad==230235
tab dyad if missing==1 & year>1814 & year<1861
//German/Italian states comprise 30/36 dyads (83.33%) and 933/1077 dyad-years (86.63%) of missing data in period 1815-1860.


**FIGURE 3: MONADIC DATA ANALYSIS
use "Replication - IBAD Full Settle Monadic.dta", clear
sort year
by year: egen meanpctsettle=mean(pctsettle) if pctsettle!=.
graph twoway line meanpctsettle year if pctsettle!=.

*To discuss specific values, look at meanpctsettle over time within one dyad with long history (e.g., France)
list year meanpctsettle if ccode==220

*III. IBAD STRATEGY DATA
use "Replication - IBAD Settlement Process Attempt-Year.dta", clear
sort dyad intstartyear

*Create party variable (1=disputants only, 2=tp, 2.5=tp and col, 3=colpower).
gen party=2 if tpcode!=.
replace party=3 if colpower1!=.
replace party=1 if tpcode==. & colpower1==.
replace party=2.5 if colpower1!=. & tpcode!=.
tab party if ongoing==0
//41.42% disputants only, 17.80% tp, 2.13% both tp and col, and 38.65% colonial).

*Describe involvement of third-parties
tab tpcode if ongoing==0
tab tpcode2 if ongoing==0
tab tpcode3 if ongoing==0
tab tpcode4 if ongoing==0
tab tpcode5 if ongoing==0
tab tpcode6 if ongoing==0
tab tpcode7 if ongoing==0
tab tpcode8 if ongoing==0
//Note: must sum across tpcodes to get total involvement of individual third parties.

*Describe involvement of colonial powers
tab colpower1 if ongoing==0
tab colpower2 if ongoing==0
tab colpower3 if ongoing==0
//Note: must sum across colpower codes to get total involvement of individual colonial powers.

*Describe strategy usage
tab ongoing
//Unique attempts: ongoing==0

tab negotiation if ongoing==0
tab mediation if ongoing==0
tab arbitration if ongoing==0
tab adjudication if ongoing==0
tab force if ongoing==0
tab postwarconference if ongoing==0
tab plebiscite if ongoing==0
tab internaldecreeadmin if ongoing==0


*FIGURE 5
sort intstartyear
by intstartyear: egen qutotalnegotiation=total(negotiation) if ongoing==0
by intstartyear: egen qutotalmediation=total(mediation)if ongoing==0
by intstartyear: egen qutotalarbitration=total(arbitration)if ongoing==0
by intstartyear: egen qutotaladjudication=total(adjudication)if ongoing==0
by intstartyear: egen qutotalforce=total(force)if ongoing==0
by intstartyear: egen qutotalpostwarcon=total(postwarconference)if ongoing==0
by intstartyear: egen qutotalpleb=total(plebiscite)if ongoing==0
by intstartyear: egen qutotalinternaldecreeadmin=total(internaldecreeadmin)if ongoing==0
by intstartyear: egen qutotalagreement=total(agreement) if ongoing==0

graph twoway line qutotalnegotiation intstartyear if intstartyear>1815
graph twoway line qutotalmediation intstartyear if intstartyear>1815
graph twoway line qutotalarbitration intstartyear if intstartyear>1815
graph twoway line qutotaladjudication intstartyear if intstartyear>1815
graph twoway line qutotalforce intstartyear if intstartyear>1815
graph twoway line qutotalpostwarcon intstartyear if intstartyear>1815
graph twoway line qutotalpleb intstartyear if intstartyear>1815
graph twoway line qutotalinternaldecre intstartyear if intstartyear>1815
graph twoway line qutotalagreement intstartyear if intstartyear>1815

//Above panels can be saved and combined into one figure using the following command:
//graph combine "QuNegotiation.gph" "QuMediation.gph" "QuArbitration.gph" "QuAdjudication.gph" "QuPostWarConf.gph" "QuPlebiscite.gph" "QuInternal Decree.gph" "QuAgreement.gph", r(4) c(2) altshrink
//In graph editor: Graph>region>margin>medium. Aspect/size: aspect ratio=0.40, position=center, y/x size=4, scaling factor=1.5

*TABLE 1. STRATEGY USAGE BY THIRD PARTY AND COLONIAL ACTORS
*Strategy usage by third parties
tab negotiation if ongoing==0 & tpcode!=.
tab mediation if ongoing==0 & tpcode!=.
tab arbitration if ongoing==0 & tpcode!=.
tab adjudication if ongoing==0 & tpcode!=.
tab force if ongoing==0 & tpcode!=.
tab postwarconference if ongoing==0 & tpcode!=.
tab plebiscite if ongoing==0 & tpcode!=.
tab internaldecreeadmin if ongoing==0 & tpcode!=.

*Strategy usage by colonial powers
tab negotiation if ongoing==0 & colpower1!=.
tab mediation if ongoing==0 & colpower1!=.
tab arbitration if ongoing==0 & colpower1!=.
tab adjudication if ongoing==0 & colpower1!=.
tab force if ongoing==0 & colpower1!=.
tab postwarconference if ongoing==0 & colpower1!=.
tab plebiscite if ongoing==0 & colpower1!=.
tab internaldecreeadmin if ongoing==0 & colpower1!=.

*Describe number of agreements
tab agreement if ongoing==0

* Find unique conflict management attempts: a) tag unique, b) running sum of unique, c) maximum of running sum.
gen unique=1 if ongoing==0
replace unique=0 if unique==.
sort dyad
by dyad: gen sumunique=sum(unique) 
by dyad: egen maxunique=max(sumunique)
tab maxun
by dyad: gen obs=_n

tab unique

*ICOW COMPARISON
*TABLE D1. ICOW CLAIMS AND BORDER SETTLEMENT
use "Replication - IBAD Full Settle Dyad-Year.dta", clear
drop if year>2001
keep if conttype==1
tab ICOWterrclaim settle if conttype==1, col chi2 gamma

*Difference in Means: Salience, Tangible and Intangible Salience
*Overall claim salience (presented in text) 
ttest maxicowsal if ICOWterrclaim==1, by(settle)
ttest maxicowsalc if ICOWterrclaim==1, by(settle)
*Tangible salience (presented in text)
ttest maxsaltan if ICOWterrclaim==1, by(settle)
*Intangible salience (presented in text) 
ttest maxsalint if ICOWterrclaim==1, by(settle)

use "Replication - IBAD ICOW Claim Comparison.dta", clear
tab conttype if obs==1
tab settle if obs==1
tab postsettleclaim if obs==1
tab settleduringclaim if obs==1
//47 of 238 (19.75%) claims that begin pre-settlement cross settlement threshold. Remainder end before settlement.

ttest claimlength if obs==1, by(postsettleclaim)
ttest maxicowsal if obs==1, by(postsettleclaim)
ttest maxicowsalc if obs==1, by(postsettleclaim)
ttest maxsaltan if obs==1, by(postsettleclaim)
ttest maxsalint if obs==1, by(postsettleclaim)

*Re-run salience using claim-year instead of claim as unit of analysis
ttest salint , by(postsettleclaim)
ttest saltan , by(postsettleclaim)
ttest icowsal , by(postsettleclaim)
ttest icowsalc , by(postsettleclaim)

ttest island if obs==1, by(postsettle)
ttest colonial if obs==1, by(postsettle)

*TABLE D2. ICOW COMPARISON BY REGION
tab region postsettleclaim if obs==1, r
list dyad year if obs==1 & region==2 & postsettleclaim==1

ttest maxmidiss if obs==1, by(postsettleclaim)
ttest maxmidfat if obs==1, by(postsettleclaim)
ttest maxwaryr if obs==1, by(postsettleclaim)
 

**TABLE D3. TERRITORIAL TRANSFERS AND BORDER SETTLEMENT.
use "Replication - IBAD Full Settle Dyad-Year.dta", clear
drop if year>2001
keep if conttype==1
tab terrchange settle, col chi2 gamma


**TABLE D4. REGIONAL DISTRIBUTION OF TERRITORIAL TRANSFERS IN CONTIGUOUS DYADS
use "Replication - IBAD Territorial Change Comparison.dta", clear
tab terrchange settle if conttype==1
tab dyad if terrchange==1 & conttype==1 & settle==1
*115 dyads post-settlement with territorial change

tab region settle if conttype==1, r

*All reported results for one-tailed ttest.
ttest conquest if conttype==1, by(settle)
ttest annex if conttype==1, by(settle)
ttest cession if conttype==1, by(settle)
ttest secession if conttype==1, by(settle)
ttest conflict if conttype==1, by(settle)
ttest area if conttype==1, by(settle)

